package com.mt.roll.process.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.EnabledParam;
import com.mt.roll.core.params.IdListParam;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdListVo;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.process.params.ProcessFlowParam;
import com.mt.roll.process.params.ProcessFlowQueryParam;
import com.mt.roll.process.service.ProcessFlowService;
import com.mt.roll.process.vo.BomVo;
import com.mt.roll.process.vo.ProcessFlowVo;
import com.mt.roll.process.vo.SubstrateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;
import java.util.List;

/**
 * @author lgh
 * @date 2020/12/29
 * @since 1.0
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_PROCESS + "process-flow")
@Slf4j
@Api(value = "工艺管理", tags = "工艺管理", hidden = false)
public class ProcessFlowController extends BaseController {
    @Autowired
    private ProcessFlowService processFlowService;

    @PostMapping(value = "getCode")
    @ApiOperation(value = "获取生成的工艺编码")
    private R<String> getCode() {
        return processFlowService.getCode();
    }


    @PostMapping(value = "get")
    @ApiOperation(value = "获取详情")
    private R<ProcessFlowVo> get(@Validated @RequestBody IdParam idParam) {
        return processFlowService.get(idParam);
    }

    @PostMapping(value = "list")
    @ApiOperation(value = "获取工艺列表")
    private R<List<ProcessFlowVo>> list(@Validated({Default.class}) @RequestBody ProcessFlowQueryParam processFlowQueryParam) {
        return processFlowService.list(processFlowQueryParam);
    }

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页工艺列表")
    private R<PageVo<ProcessFlowVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody ProcessFlowQueryParam processFlowQueryParam) {
        return processFlowService.page(processFlowQueryParam);
    }

    @PostMapping(value = "tree")
    @ApiOperation(value = "获取xx树列表",hidden = true)
    private R<List<ProcessFlowVo>> tree(@Validated({Default.class}) @RequestBody ProcessFlowQueryParam processFlowQueryParam) {
        return processFlowService.tree(processFlowQueryParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody ProcessFlowParam processFlowParam) {
        return processFlowService.add(processFlowParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody ProcessFlowParam processFlowParam) {
        return processFlowService.update(processFlowParam);
    }

    @PostMapping(value = "enabled")
    @ApiOperation(value = "启停工艺")
    private R<IdVo> enabled(@Validated @RequestBody EnabledParam enabledParam) {
        return processFlowService.enabled(enabledParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除工艺")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return processFlowService.delete(idParam);
    }

    @PostMapping(value = "batchDelete")
    @ApiOperation(value = "批量删除xx",hidden = true)
    private R<IdListVo> delete(@Validated @RequestBody IdListParam idListParam) {
        return processFlowService.delete(idListParam);
    }

/*    @PostMapping(value = "substrateList")
    @ApiOperation(value = "获取基板列表")
    private R<List<SubstrateVo>> substrateList() {
        return processFlowService.substrateList();
    }

    @PostMapping(value = "bomList")
    @ApiOperation(value = "获取BOM列表")
    private R<List<BomVo>> bomList() {
        return processFlowService.bomList();
    }*/
}
